package com.zzq.my.jetpacks.jectpackapp.net.loadCaptcha

import com.zzq.my.jetpacks.jectpackapp.net.ApiService
import com.zzq.my.jetpacks.jectpackapp.net.ApiUrl
import com.zzq.my.jetpacks.net.base.BaseRepository
import com.zzq.my.jetpacks.net.base.RetrofitClient
import okhttp3.Response
import okhttp3.ResponseBody
import rxhttp.RxHttp
import rxhttp.awaitResult
import rxhttp.onErrorReturn
import rxhttp.toOkResponse

/**
 * 描述：获取图形验证码
 * 作者：zhuangzeqin
 * 时间: 2022/1/20-10:41
 * 邮箱：zzq@eeepay.cn
 * 备注:
 */
class LoadCaptchaRepo:BaseRepository() {
    private val mApiService by lazy {
        RetrofitClient.getInstance().create(ApiService::class.java)
    }

    suspend fun reqLoadCaptcha(): ResponseBody? = executeBeanHttp { mApiService.loadCaptcha()}

    suspend fun reqLoadCaptcha2():Result<Response>
    {
        //转换为原始的Response
        return RxHttp.get(ApiUrl.LOADCAPTCHA).toOkResponse().awaitResult()
    }

}